import os
from comm.functons import scan_videos, config


def convert(v_raw):
    to_mp4 = config('mp4_dir') + os.path.basename(v_raw) + '.mp4'
    if os.path.exists(to_mp4):
        print('已存在 {}'.format(to_mp4))
        return
    cmd = 'ffmpeg -i "{}" "{}"'.format(v_raw, to_mp4)
    os.system('chcp 65001')  # 控制台编码
    os.system(cmd)
    # print(cmd)
    # exit()


if '__main__' == __name__:
    videos = scan_videos(r'E:\迅雷下载', ['ts'])
    # videos = [
    #     r"E:\迅雷下载\录影片段.Klip.2012.RS.SUBBED.BluRay.1920x920p.x264.AC3-中文字幕.mkv",
    # ]
    for vp in videos:
        convert(vp)
